import { createApp } from 'vue';
import App from './App.vue';
import { createRouter, createWebHistory } from 'vue-router';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import _axios from 'axios';

export const axios = _axios.create({
    baseURL: import.meta.env.VITE_API_BASE_URL,
    headers: {
        'X-Requested-With': 'XMLHttpRequest',
    },
});

const router = createRouter({
    ...('production' === import.meta.env.MODE ? {
        history: createWebHistory('/admin/'),
    } : {
        history: createWebHistory(),
    }),
    routes: [
        {
            path: '/',
            component: () => import('./pages/Layout.vue'),
            children: [
                {
                    path: '',
                    component: () => import('./pages/Index.vue'),
                },
                {
                    path: 'users',
                    component: () => import('./pages/Users.vue'),
                },
            ],
        },
    ],
});

const app = createApp(App);

app.use(router);
app.use(ElementPlus, {
    size: 'small',
    zIndex: 3000,
    locale: zhCn,
});

app.mount('#app');
